package XZK010305.net;

import java.io.*;
import java.net.Socket;

import XZK010305.ExpressClient;

/**
 * <p>
 * 模拟客户端
 * </p>
 *
 * @author bing.z 2021/6/22 14:31
 **/
public class Client {
    public static void main(String[] args) {
        ExpressClient client = new ExpressClient();
        // 创建客户端 socket
        try (Socket socket = new Socket("127.0.0.1", 10086);) {
            System.out.println("客户端连接成功！");
            // 获取输入输出流
            OutputStream os = socket.getOutputStream();
            ObjectOutputStream oos = new ObjectOutputStream(os);
            InputStream is = socket.getInputStream();
            ObjectInputStream ois = new ObjectInputStream(is);
            // 调用客户端业务方法
            client.start(ois, oos);
        } catch (IOException | ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}
